import React, { FC, JSX } from "react";
import Script from "next/script";
import styles from './Common.module.scss'

type PageWrapperProps = {
  title: string;
  desc?: string;
  css?: string;
  js?: string;
  children: JSX.Element | JSX.Element[];
};

const PageWrapper: FC<PageWrapperProps> = ({
  title,
  desc = "",
  css = "",
  js = "",
  children,
}: PageWrapperProps) => {
  return (
    <>
      {title && <title>{title}</title>}
      {desc && <meta name="description" content={desc} />}
      {css && <style>{css}</style>}
      <main className={styles.container}>{children}</main>
      <Script id="page-js">{js}</Script>
    </>
  );
};

export default PageWrapper;
